<template>
    <div class="list">
        <h1>购物车列表</h1>
        <div class="item" v-for="item in items" :key="item.id">           
                <img class="item-img" :src="item.src" alt="">         
                <div class="item-title">
                    {{item.title}}<small>x{{item.num}}</small>
                </div>
                <div class="item-price">{{item.price | currency}}</div>
                <div class="item-opt">
                    <button @click="del(item.id)">删除</button>
                </div>      
        </div>
        <div class="item-total" v-if="items.length">
            商品总价：{{total | currency}}
        </div>
        <div class="item-empty" v-else>购物车中暂无商品</div>
    </div>
</template>
<script>
    import {mapGetters,mapState,mapActions} from 'vuex'

    export default{
        computed:{
            ...mapState({
                items:state => state.shopcart.items
            }),
            ...mapGetters('shopcart',{total:'totalPrice'})
        },
        methods:mapActions('shopcart',['del']),
        filters:{
            currency(value){
                return '￥'+value
            }
        }
    }
</script>
<style scoped>
h1{
    text-align: center;
    font-weight: 600;
    margin-bottom: 0;
    text-shadow: 2px 2px 5px lightgray;
}
.list{
    width: 100%;
    height: 680px;
    position: fixed;
    top:0;
    left:0;
    background:url(~/static/bg3.jpg);
    background-repeat: no-repeat;
    min-width: 1000px;
    background-size:100% 100%;

    /* float: left; */
}
.item{
    width: 150px;
    height: 210px;
    /* background-color:pink; */
    text-align: center;
    float: left;
    margin-left: 55px;
    margin-top: 20px;
    background-color: rgba(255,255,255,0.5);
    box-shadow: 10px 10px 15px -10px;
}
.item-total{
    width: 250px;
    height: 45px;
    line-height: 45px;
    float: right;
    color: blue;
    text-align: center;
    border-radius: 5px;
    margin-right: 250px;
    margin-top: -40px;
    font-weight: 600;
    background-color:lightblue;
}
.item-empty{
    margin-top: 20px;
    margin-left: 40px;
    font-weight: 600;
}
img{
    width: 83px;
    height: 83px;
    margin-top: 20px;
    border: 2px solid blue;
    border-radius: 10px 0 10px 0;
}
small{
    color: red;
    font-weight: 700;
}


</style>